package info.manxi;

import akka.actor.AbstractActor;
import akka.actor.ActorRef;
import akka.actor.Props;

import java.math.BigDecimal;

/**
 * <pre>
 * <b>Description</b>
 * </pre>
 * <pre>
 * 创建时间 2019-11-25 15:28
 * 所属工程： akka-actor-101  </pre>
 *
 * @author sheldon yhid: 80752866
 */
public class Boy extends AbstractActor {
    static Props props() {
        return Props.create(Boy.class, Boy::new);
    }

    @Override
    public Receive createReceive() {
        return receiveBuilder()
                .match(String.class, msg -> {
                    System.out.println("我收到了" + getSender() + "的消息：" + msg);
                    if (msg.equals("You can try!")) {
                        System.out.println("天哪！我要发了");
                        ActorRef 无名少女 = getContext().getSystem().actorOf(Girl.props(), "gossipgirl");
                        Love love = new Love();
                        love.setMoney(new BigDecimal("99999999"));
                        love.setMsg("我不是维特 我是王老五");
                        无名少女.tell(love, getSelf());
                        return;
                    }
                    getSender().tell("Yes I do", getSelf());
                })
                .build();
    }
}
